package com.ruoyi.fankui.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fankui.domain.Fankui;
import com.ruoyi.fankui.service.IFankuiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审核反馈Controller
 * 
 * @author ruoyi
 * @date 2023-04-06
 */
@Controller
@RequestMapping("/fankui/fankui")
public class FankuiController extends BaseController
{
    private String prefix = "fankui/fankui";

    @Autowired
    private IFankuiService fankuiService;

    @RequiresPermissions("fankui:fankui:view")
    @GetMapping()
    public String fankui()
    {
        return prefix + "/fankui";
    }

    /**
     * 查询审核反馈列表
     */
    @RequiresPermissions("fankui:fankui:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Fankui fankui)
    {
        startPage();
        List<Fankui> list = fankuiService.selectFankuiList(fankui);
        return getDataTable(list);
    }

    /**
     * 导出审核反馈列表
     */
    @RequiresPermissions("fankui:fankui:export")
    @Log(title = "审核反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Fankui fankui)
    {
        List<Fankui> list = fankuiService.selectFankuiList(fankui);
        ExcelUtil<Fankui> util = new ExcelUtil<Fankui>(Fankui.class);
        return util.exportExcel(list, "审核反馈数据");
    }

    /**
     * 新增审核反馈
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存审核反馈
     */
    @RequiresPermissions("fankui:fankui:add")
    @Log(title = "审核反馈", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Fankui fankui)
    {
        return toAjax(fankuiService.insertFankui(fankui));
    }

    /**
     * 修改审核反馈
     */
    @RequiresPermissions("fankui:fankui:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Fankui fankui = fankuiService.selectFankuiById(id);
        mmap.put("fankui", fankui);
        return prefix + "/edit";
    }

    /**
     * 修改保存审核反馈
     */
    @RequiresPermissions("fankui:fankui:edit")
    @Log(title = "审核反馈", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Fankui fankui)
    {
        return toAjax(fankuiService.updateFankui(fankui));
    }

    /**
     * 删除审核反馈
     */
    @RequiresPermissions("fankui:fankui:remove")
    @Log(title = "审核反馈", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(fankuiService.deleteFankuiByIds(ids));
    }
}
